package view;


import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.TextArea;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSplitPane;

import client.ClientUser;
import controller.EditeurActionController;
import controller.ExempleModelController;
import controller.FileController;
import controller.Interpreteur;
import controller.TortueController;

public class ProgramView extends JFrame{
	
	private String user;
	private ClientUser clientUser;
	private TextArea fileArea;
	private FileController fileController;
	private FileView fileView;
	private  ChatView chatView;
	
	public ProgramView(ClientUser clientUser){
		this.clientUser = clientUser;
	}
	
	public void initialize(){
		//super();
        this.setTitle("Bienvenue :: "+clientUser.getClient().getName());
        this.setSize(new Dimension(1100, 700));
        this.setLocationRelativeTo(null);
        
        
        /*Editeur*/
        EditeurUI editeur = new EditeurUI();
        JPanel panelEditeur = new JPanel();
        panelEditeur.add(editeur);
	 	panelEditeur.setBorder(BorderFactory.createTitledBorder("Editeur"));
        
	 	/*Zone graphique*/
	 	JPanel zoneGraphique = new JPanel();
        ZoneDessin zoneDessin = new ZoneDessin();
	 	zoneGraphique.setBorder(BorderFactory.createTitledBorder("Dessin"));
	 	zoneGraphique.add(zoneDessin);
    	
	 	/* Zone exemple*/
        ExempleModelController zoneController = new ExempleModelController();
        ZoneExemple zoneExemple = new ZoneExemple(zoneController);
        zoneController.setZoneExemple(zoneExemple);
        
        TortueController tortueController = new TortueController(zoneDessin);
        EditeurActionController editeurActionController = new EditeurActionController(editeur, zoneDessin);
        EditeurActionUI editeurActions = new EditeurActionUI(editeurActionController, new Interpreteur(editeur, zoneDessin, tortueController));
        //ZoneDessin zonneDessin = new ZoneDessin();

      
        BarreMenu barreMenu = new BarreMenu(editeurActionController);
        
        /*ZONE RIGHT*/
        JPanel zoneRight = new JPanel();
        zoneRight.setLayout(new BoxLayout(zoneRight, BoxLayout.Y_AXIS));
        zoneRight.add(zoneExemple, BorderLayout.NORTH);
        zoneRight.add(chatView,BorderLayout.SOUTH);
        
        
        
        /*ZONE CENTER*/
        //JSplitPane split = new JSplitPane();
        JPanel zoneCenter = new JPanel();
        zoneCenter.setLayout(new BoxLayout(zoneCenter, BoxLayout.Y_AXIS));
        zoneCenter.add(zoneGraphique);
        
        zoneCenter.add(editeurActions);
        zoneCenter.add(panelEditeur);


        /* Agencement des différents panels*/
        this.add(zoneRight,BorderLayout.EAST);
        this.add(barreMenu, BorderLayout.NORTH);
        this.add(fileView, BorderLayout.WEST);
        this.add(zoneCenter,BorderLayout.CENTER);
        
        this.setResizable(true);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);

	}


	/**
	 * @return the user
	 */
	public String getUser() {
		return user;
	}

	/**
	 * @param user the user to set
	 */
	public void setUser(String user) {
		this.user = user;
	}

	/**
	 * @return the clientUser
	 */
	public ClientUser getClientUser() {
		return clientUser;
	}

	/**
	 * @param clientUser the clientUser to set
	 */
	public void setClientUser(ClientUser clientUser) {
		this.clientUser = clientUser;
	}

	/**
	 * @return the fileView
	 */
	public FileView getFileView() {
		return fileView;
	}

	/**
	 * @param fileView the fileView to set
	 */
	public void setFileView(FileView fileView) {
		this.fileView = fileView;
	}

	/**
	 * @return the chatView
	 */
	public ChatView getChatView() {
		return chatView;
	}

	/**
	 * @param chatView the chatView to set
	 */
	public void setChatView(ChatView chatView) {
		this.chatView = chatView;
	}


}
